from sanic.response import json, JSONResponse


def CustomerResponse(code=200, data={}, message="") -> JSONResponse:
    """ 默认返回json """
    # 结构化返回数据
    dict_data = {
        "error": code,
        "data" : data
    }

    # 存在提示文字则添加
    if message:
        dict_data["message"] = message

    return json(body=dict_data)